import {Http} from '@angular/http';
import {Component}  from '@angular/core';
import { Notify } from "app/Service";

/**
 * 图标编辑区域组件
 */
@Component({
	selector: ".main_body",
	template: '<div class="login_pane" (loginSuccess)="loginSuccess($event)" *ngIf="!hasLogin"></div>'+
				'<aside class="menu side_menu" *ngIf="hasLogin"></aside>'+
				'<div class="work_pane"  [ngClass]="{hide: !hasLogin}"></div>'
})
export class AppComp {
	hasLogin:boolean = false;
	constructor(private http:Http, private notify:Notify){
		this.http.get({
			search:{
				m:"Admin",
				c:"ApiSchool",
				a:"getOrderList",
				page:1,
				count:1
			}
		}).then((data)=>{
			this.hasLogin = true;
		});
		
		notify.subscribe((login)=>{
			this.hasLogin = login;
		})
	}
	
	//登录成功
	loginSuccess(login: boolean) {
		this.http.get({
			search:{
				m:"Admin",
				c:"ApiBox",
				a:"getBoxBySchool"
			}
		}).then((data)=>{
			this.hasLogin = true;
			this.hasLogin = login;
		});
	}
}